<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/common/backcommon.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Breaking Fast</title>
		<script type="text/javascript">
			$(function() {
				$.ajax({
					url: "${base}/backDishCtl/selectDishType",
					type: "post",
					success: function(result){
						var dishtype = $("#dishtype");
						for(var i = 0; i < result.length; i++) {
							var selected = "${dish.dishtypeid}" == result[i].dishtypeid ? "selected" : "";
							dishtype.append("<option value='" + result[i].dishtypeid + "' " + selected  +" >" + result[i].typechname + "</option>");
						}
					}
				});
				//验证信息
				$.formValidator.initConfig({
					formID: "addForm",
					debug:false,
					onError: function(msg, obj, errorlist){
						alert(msg);
					}
				});
				$("#dishchname").formValidator({onShow:"请输入中文菜名", onCorrect:"恭喜你,你输对了"}).inputValidator({min:1, max:25, onError:"中文菜名为0-25个字"}).regexValidator({regExp: "Illegal", dataType:"enum", onError:"中文菜名中包含非法字符"});
				$("#dishenname").formValidator({onShow:"请输入英文菜名", onCorrect:"恭喜你,你输对了"}).inputValidator({min:1, max:25, onError:"英文菜名为0-25个字符"}).regexValidator({regExp: "enname", dataType:"enum", onError:"英文菜名中包含非法字符"});
				$("#price").formValidator({tipID:"priceMinTip", onShow: "请输入数字", onCorrect: "恭喜你,你输对了"}).inputValidator({min:0.1, max:9999, onError:"单价在0-9999之间"}).inputValidator({min:0, max:999, type:"value", onErrorMin:"你输入的值必须大于等于0", onError:"单价必须在0-999之间，请确认"});
				//$("#dishImage").formValidator({triggerEvent:"change",onShow:"请修改您的菜品图片", onFocus:"图片格式可以为jpg|bmp|gif|jpeg|png", onCorrect:"恭喜您，图片可用" }).regexValidator({regExp:"picture",dataType:"enum", onError:"图片格式不正确"});
				$("#remark").formValidator({empty:true, onShow:"请输入备注信息", onCorrect:"恭喜你,你输对了"}).inputValidator({max:500, onError:"你输入的备注信息太长"}).regexValidator({regExp: "Illegal", dataType:"enum", onError:"备注信息中包含非法字符"});
				$("#rests").formValidator({empty:true, onShow:"请输入其他信息", onCorrect:"恭喜你,你输对了"}).inputValidator({max:50, onError:"你输入的其他信息太长"}).regexValidator({regExp: "Illegal", dataType:"enum", onError:"其他信息中包含非法字符"});
			});
		</script>
	</head>
	<body>
		<div class="cms_right">
		  	<div class="cms_title">
		    	<span>菜品管理：修改 </span>
		    </div>
		    <div class="cms_search">
		    	<form:form id="addForm" commandName="dish" action="${base}/backDishCtl/update" method="post" enctype="multipart/form-data">
					<table width="1000" border="0" class="search_bd">
			          	<tr>
				            <td class="yh_name">中文菜名：</td>
				            <td class="yh_bd"><input type="text" id="dishchname"name="dishchname" maxlength="25" class="cms_text02" value="${dish.dishchname }" /></td>
				            <td class="tishi"><div id="dishchnameTip" ></div></td>
				            <td class="yh_name">英文菜名：</td>
				            <td class="yh_bd"><input type="text" id="dishenname"name="dishenname" maxlength="25" class="cms_text02" value="${dish.dishenname }" /></td>
				            <td class="tishi"><div id="dishennameTip" ></div></td>
			          	</tr>
			          	<tr>
				            <td class="yh_name">单价：</td>
				            <td class="yh_bd"><input type="text" id="price" name="price" class="cms_text02" maxlength="4" value="${dish.price }" /></td>
				            <td class="tishi"><div id="priceTip"></div></td>
				            <td class="yh_name">类型：</td>
				            <td class="yh_bd">
				            	<select id="dishtype" name="dishtypeid">
					            	<option value="" selected="selected">=请选择=</option>
				            	</select>
				            </td>
				            <td class="tishi"><div id="priceTip"></div></td>
			          	</tr>
			          	<tr>
				            <td class="yh_name">图片：</td>
				            <td class="yh_bd" colspan="4"><input type="file" id="dishImage" name="dishImage" maxlength="50" style="width: 80%" value="${dish.photo }"/></td>
				            <td class="tishi"><div id="dishImageTip"></div></td>
			          	</tr>
			          	<tr>
				            <td class="yh_name">备注：</td>
				            <td colspan="4">
				            	<textarea id="remark" name="remark" rows="3" cols="100" style="border:1px solid #a0a0a0;resize:none">${dish.remark }</textarea>
				            </td>
				            <td class="tishi"><div id="remarkTip"></div></td>
			          	</tr>
			          	<tr>
				            <td>
				            	<input type="hidden" name="dishid" value="${dish.dishid }" />
				            	<input type="hidden" name="photo" value="${dish.photo }" />
				            </td>
				            <td align="right"><input type="reset" class="search_btn" value="重置" /></td>
				            <td align="center"><input type="button" class="search_btn" onclick="location.href='${base}/background/dish/dishlist.jsp'" value="返回" /></td>
				            <td><input type="submit" class="search_btn" value="确定" /></td>
				            <td>&nbsp;</td>
				            <td>&nbsp;</td>
						</tr>
					</table>
				</form:form>
			</div>
		</div>
	</body>
</html>
	